﻿using SharpSoft.WPF.Adorners;
using SharpSoft.WPF.Controls;
using SharpSoft.WPF.Masks;
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Documents;

namespace SharpSoft.WPF.Masks
{
    /// <summary>
    /// 用于操作Toast提示信息
    /// </summary>
    public class Toast : IMaskOperator
    {
        public Toast(VisualAdorner adorner, AdornerLayer adornerLayer)
        {
            this.Adorner = adorner;
            this.AdornerLayer = adornerLayer;
        }
        /// <summary>
        /// 装饰器对象
        /// </summary>
        public VisualAdorner Adorner { get; internal set; }

        /// <summary>
        /// 所属装饰器层 
        /// </summary>
        public AdornerLayer AdornerLayer { get; internal set; }

        public MaskLayout MaskLayout
        {
            get
            {
                return this.Adorner.ContentVisual as MaskLayout;
            }
        }

        public ToastTemplate ToastTemplate
        {
            get
            {
                return this.MaskLayout.MaskContent as ToastTemplate;
            }
        }
        public void Close()
        {
            if (this.Adorner != null && this.AdornerLayer != null)
            {
                this.AdornerLayer.Remove(this.Adorner);
            }
        }

        public void Open()
        {

            if (this.Adorner != null && this.AdornerLayer != null)
            {
                this.AdornerLayer.Add(this.Adorner);
            }
        }
    }
}
